<template>
  <div class="sendcar">
    <div class="rj-wrap">
      派车信息
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" /></a></div>
    <form method="post" id="formid">
      <div class="weui-tab">
        <div class="weui-navbar">
          <a class="weui-navbar__item" href="#tab1">订单信息</a>
          <a class="weui-navbar__item weui-bar__item_on" href="#tab2">派车信息</a>
          <!--          <a class="weui-navbar__item" href="#tab3">海运派车</a>-->
        </div>
        <div class="weui-tab__panel">
          <div id="tab1" class="weui_tab_bd_item">
            <div class="weui-cells weui-cells_form">
<!--              <input name="entity.guid" id="guid" type="hidden" v-model="adata.guid" />-->
              <input name="orderCode" type="hidden" v-model="order.code" />
              <input name="orderId" id="orderid" type="hidden" v-model="order.guid" />
              <input name="sellType" id="sellType" type="hidden" value="sendCar" />
<!--              <input name="entity.wlcode" id="wlcompanyguid" v-model="adata.wlcode" type="hidden" />-->
<!--              <input name="entity.code" id="code" v-model="adata.code" type="hidden" />-->
              <input name="wlstatus" id="wlstatus" v-model="wlinfoitem.wlstatus" type="hidden" />
<!--              <input name="entity.faretype" id="faretype" v-model="adata.faretype" type="hidden" />-->
<!--              <input name="entity.farepricetype" id="farepricetype" v-model="adata.farepricetype" type="hidden" />-->
              <input name="isSendCar" id="isSendCar" v-model="isSendCar" type="hidden" />
              <input name="sendcarguid" id="sendcarguid" v-model="sendcarguid" type="hidden" />
<!--              <input name="entitySea.seaguid" id="seaguid" v-model="bdata.guid" type="hidden" />-->
              <input name="entity.type" id="type" value="2" type="hidden" />
              <div class="cellgroup">
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">订单编号</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="text" readonly id="sellcode" v-model="order.sellcode" name="sellcode" placeholder="请输入订单编号"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">申请人</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" id="applyname" readonly type="text" name="applyname" v-model="order.applyname" placeholder="请输入申请人"></div>
                </div>
              </div>
              <div class="cellgroup">
                <div class="weui-cell fir">
                  <div class="weui-cell__hd">
                    <label class="weui-label">发货联系人</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" id="delicontact" name="entity.delicontact" v-model="adata.deliContact" placeholder=" 请输入发货联系人"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">联系电话</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="number" id="delicontacttel" name="entity.delicontacttel" v-model="adata.deliContactNo" placeholder=" 请输入发货人手机号"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label id='unqualifiedchkrateDiv' class="weui-label">发货地址</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="text" id='deliprovince' name="entity.deliprovince"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">详细地址</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="text" id='deliaddress' name="entity.deliaddress" v-model="adata.deliAddress" placeholder=" 请输入发货详细地址"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">收货联系人</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" id="arricontact" name="entity.arricontact" v-model="adata.arriContact" placeholder="请输入收货联系人"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">联系电话</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="number" id="arricontactno" name="entity.arricontactno" v-model="adata.arriContactNo" placeholder=" 请输入收货人手机号"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">收货地址</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="text" id='arriprovince' name="entity.arriprovince"></div>
                </div>
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">详细地址</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" type="text" id='arriaddres' name="entity.arriaddres" v-model="adata.arriAddress" placeholder=" 请输入收货详细地址"></div>
                </div>
                <div class="weui-cell" v-if="orderfiles.length > 0">
                  <div class="weui-cell__hd"><label class="weui-label">附件</label></div>
                  <div class="weui-cell__bd">
                    <a v-for="(item, index) in orderfiles" :href="item.url">
                      <input class="weui-input" type="text" name="" :value="item.filename">
                    </a>
                    <!--              <input class="weui-input" type="text" name="" v-model="baseInfo.createtime">-->
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div id="tab2" class="weui_tab_bd_item weui_tab_bd_item_active">
            <div class="weui-cells weui-cells_form">
              <div class="weui-cell fir" style="position: relative;">
<!--                <div class="delsty"><i class="weui-icon-cancel" v-on:click="deleteCar"></i></div>-->
                <div class="weui-cell__hd">
                  <label class="weui-label">运输方式</label></div>
                <div class="weui-cell__bd">
                  <select class="weui-select" name="entity.transtype" v-model="transType">
                    <option value="1">派车</option>
                    <option value="3">快递</option>
                  </select>
                </div>
                <!--                  <input class="weui-input" ref="boxType" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.boxType" v-model="bdata.boxType"  placeholder="请输入箱型"></div>-->
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">物流公司</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-select" type="hidden" name="entity.customerid" v-model="wlcompany.guid" id="customerid">
                  <input class="weui-select" type="hidden" name="entity.customername" v-model="wlcompany.name" >
                  <select class="weui-select" v-model="wlcompany" :disabled="wlinfoitem.wlstatus == 2" >
                    <option value="">请选择</option>
                    <option v-for="(item) in wlcompanys" :value="item">{{item.name}}</option>
                  </select>
                </div>
<!--                  <input class="weui-select" type="hidden" name="entity.customerid" v-model="adata.customerid" id="customerid" placeholder="请输入物流公司">-->
<!--                  <input class="weui-select" type="text" name="entity.customername" id="customername" :disabled="wlinfoitem.wlstatus == 2" v-model="adata.customername" placeholder="请输入物流公司"></div>-->
              </div>
              <div class="weui-cell" v-if="transType == 3">
                <div class="weui-cell__hd">
                  <label class="weui-label">快递单号</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" required name="entity.kdcode" placeholder="请输入快递单号">
                </div>
              </div>
              <div class="weui-cell" v-if="transType == 1">
                <div class="weui-cell__hd">
                  <label class="weui-label">司机电话</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="number" id="driverphone" @blur="getWLDriver()" name="entity.driverphone" v-model="adata.driverphone" placeholder="请输入司机联系电话"></div>
              </div>
              <div class="weui-cell" v-if="transType == 1">
                <div class="weui-cell__hd">
                  <label class="weui-label">司机姓名</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" required id="drivername" name="entity.drivername" v-model="adata.drivername" placeholder="请输入司机姓名"></div>
              </div>
                <div class="weui-cell" v-if="transType == 1">
                  <div class="weui-cell__hd">
                    <label class="weui-label" id="acts">车牌号</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui_input" style="border:0;font-size:16px;" :disabled="wlinfoitem.wlstatus == 2" name="entity.carcode" v-model="carcode" id="carcode" type="text" placeholder="请输入车牌号" @change="editCarcode" >
                  </div>
                </div>
                <div v-if="existOrderCode" style="background: #fff;text-align: right">
                    <label for="weuiAgree" class="weui-agree" style="padding-top: 0;">
                      <input id="weuiAgree" type="checkbox" checked name="pingche" value="1" class="weui-agree__checkbox">
                      <span class="weui-agree__text">
                      是否和物流订单 {{existOrderCode}} 拼车？
                    </span>
                    </label>
                </div>
              <div class="weui-cell" v-if="transType == 1">
                <div class="weui-cell__hd">
                  <label class="weui-label">车型</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entity.carType" v-model="adata.carType"  placeholder="请输入车型"></div>
              </div>
              <div class="weui-cells weui-cells_form" v-if="transType == 1">
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">结算方式</label>
                  </div>
                  <div class="weui-cell__bd">
                    <select class="weui-select" name="entity.faretype" v-model="faretype" :disabled="wlinfoitem.wlstatus == 2">
                      <option value="">请选择结算方式</option>
                      <option v-for="(item) in faretypes" :value="item.dictkey">{{item.dicttext}}</option>
                    </select>
                  </div>
                </div>
              </div>
              <div class="weui-cells weui-cells_form" v-if="transType == 1">
                <div class="weui-cell">
                  <div class="weui-cell__hd">
                    <label class="weui-label">运价</label></div>
                  <div class="weui-cell__bd">
                    <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="number" id="fareprice" name="entity.fareprice" v-model="adata.fareprice" placeholder="运价" style="width: 45%;">
<!--                    <input class="weui-select" :disabled="wlinfoitem.wlstatus == 2" type="text" id="farePriceTypeC" v-model="farepricetype" placeholder="运价方式" style="width: 51%; padding-left: 0;color:#000;"></div>-->
                    <select class="weui-select" name="entity.farepricetype" v-model="farepricetype"  style="width: 51%; padding-left: 0;color:#000;">
                      <option value="">请选择计价方式</option>
                      <option v-for="(item) in farepricetypes" :value="item.dictkey">{{packfpType(item.dictkey)}}</option>
                    </select>
                  </div>
                </div>
              </div>
              <div class="weui-cell" v-if="order.transType == 2">
                <div class="weui-cell__hd">
                  <label class="weui-label">集装箱号</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" required name="entity.boxCode" v-model="adata.boxCode" placeholder="请输入集装箱号" /></div>
              </div>
              <div class="weui-cell" v-if="transType == 1">
                <div class="weui-cell__bd">
                  <textarea class="weui-textarea opinion" id="opinion" name="opinion" v-model="adata.opinion" placeholder="请输入备注内容" rows="2"></textarea>
                </div>
              </div>
            </div>
          </div>
          <!--          <div id="tab3" class="weui_tab_bd_item">-->

          <!--            <div class="weui-cells weui-cells_form">-->
          <!--              &lt;!&ndash;              <div class="weui-cell">&ndash;&gt;-->
          <!--              &lt;!&ndash;                <div class="weui-cell__hd">&ndash;&gt;-->
          <!--              &lt;!&ndash;                  <label class="weui-label">运输方式</label></div>&ndash;&gt;-->
          <!--              &lt;!&ndash;                <div class="weui-cell__bd">&ndash;&gt;-->
          <!--              &lt;!&ndash;                  <input class="weui-input" disabled type="text" v-model="bdata.transTypeName" ></div>&ndash;&gt;-->
          <!--              &lt;!&ndash;              </div>&ndash;&gt;-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">收货港口</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.arriPort"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">收货港所属国家</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.arriPortCountry" ></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">海运环境</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.environment" ></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">提单类型</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.lifttypename" ></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">贸易条款</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.transClause" ></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">备注</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" disabled type="text" v-model="bdata.remark"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <div class="delsty"><i class="weui-icon-cancel" v-on:click="deleteSeaCar"></i></div>-->
          <!--                  <label class="weui-label">物流公司</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-select" type="hidden" name="entitySea.customeridSea" v-model="bdata.customerid" id="customeridSea">-->
          <!--                  <input class="weui-select" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.customernameSea" v-model="bdata.customername" id="customernameSea" placeholder="请选择物流公司" style="width: 80%;"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">货柜号</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" id="containerNo" name="entitySea.containerNo" v-model="bdata.containerNo" placeholder="请输入货柜号"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">发货港口</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" id="deliPort" name="entitySea.deliPort" v-model="bdata.deliPort" placeholder="请输入发货港口"></div>-->
          <!--              </div>-->

          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">货运船公司</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.shipCompany" v-model="bdata.shipCompany"  placeholder="货运船所属公司"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">船名称</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.shipname" v-model="bdata.shipname"  placeholder="请输入船名称"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">航次</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.shipCode" v-model="bdata.shipCode"  placeholder="请输入航次"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">提单号</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" ref="liftCode" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.liftCode" v-model="bdata.liftCode"  placeholder="请输入提单号"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">箱型</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <select class="weui-select" name="entitySea.boxType" ref="boxType">-->
          <!--                    <option value="">请选择</option>-->
          <!--                    <option v-for="item in boxTypes" :value="item.name" :selected="bdata.boxType == item.name">{{item.name}}</option>-->
          <!--                  </select>-->
          <!--                </div>-->
          <!--                &lt;!&ndash;                  <input class="weui-input" ref="boxType" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.boxType" v-model="bdata.boxType"  placeholder="请输入箱型"></div>&ndash;&gt;-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">箱数</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" ref="boxSize" :disabled="wlinfoitem.wlstatus == 2" type="number" name="entitySea.boxSize" v-model="bdata.boxSize"  placeholder="请输入箱数"></div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">开船日期</label>-->
          <!--                </div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input type="text" id='datetime-picker' ref="loadtime" class="weui-input time" name="loadtime" v-model="bdata.loadtime" placeholder="请选择开船日期" />-->
          <!--                </div>-->
          <!--              </div>-->
          <!--              <div class="weui-cell">-->
          <!--                <div class="weui-cell__hd">-->
          <!--                  <label class="weui-label">集装箱号</label></div>-->
          <!--                <div class="weui-cell__bd">-->
          <!--                  <input class="weui-input" ref="boxCode" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.boxCode" v-model="bdata.boxCode"  placeholder="请输入集装箱号"></div>-->
          <!--              </div>-->
          <!--            </div>-->
          <!--          </div>-->
        </div>
      </div>
      <div ref="actHtml" class="fixcont">
        <div class="weui-btn-area">
          <a class="weui-btn weui-btn_primary halfbtn subbtn" :disabled="wlinfoitem.wlstatus == 2" :class="{noprevent: wlinfoitem.wlstatus == 2}" href="javascript:" @click="send">提交</a>
          <a class="weui-btn weui-btn_primary halfbtn subbtn" v-if="refuseflag == 1" href="javascript:" @click="rejectIt">拒绝</a>
          <a class="weui-btn weui-btn_primary halfbtn" v-else href="javascript:" @click="$router.back(-1)" id="sub">返回</a></div>
      </div>
      <OrderBaseInfo :sellforms="sellforms" :transferapplys="transferapplys" :driveName="driveName"></OrderBaseInfo>
    </form>
    <div id="bmlogs">
      <SalesOperationLogs2 :nodeid="nodeid" :orderid="guid" :srguid="order.storermguid" :departid="order.depguid"></SalesOperationLogs2>
    </div>
<!--    <div class="weui-tabbar">-->
<!--      <a href="javascript:;" class="weui-tabbar__item weui-bar__item&#45;&#45;on">-->
<!--        <div class="weui-tabbar__icon">-->
<!--          <img src="@/assets/icon-pass.png" alt="">-->
<!--        </div>-->
<!--        <p class="weui-tabbar__label">通过</p>-->
<!--      </a>-->
<!--      <a href="javascript:;" class="weui-tabbar__item">-->
<!--        <div class="weui-tabbar__icon">-->
<!--          <img src="@/assets/icon-nopass.png" alt="">-->
<!--        </div>-->
<!--        <p class="weui-tabbar__label">拒绝</p>-->
<!--      </a>-->
<!--    </div>-->
  </div>
</template>

<script>
  import OrderBaseInfo from '../common/OrderBaseInfo'
  import SalesOperationLogs2 from '../common/SalesOperationLogs2'

  export default {
    name: 'SendCar',
    data () {
      return {
        guid : "",
        nodeid: '',
        status: '',
        adata: {}, //陆运
        bdata: {}, //海运
        adatas: [],
        transferapplys:[],
        sellforms:[],
        driveName:'',
        order:{},
        isSendCar: 0,  //0正常  1不能派车   2拼车,
        sendcarguid: '', //拼车的guid
        wlinfoitem: {},
        orderfiles: [],
        refuseflag: '',
        refuseNodes: [],
        boxTypes: '',
        transType: 1,
        carcode: '',
        wlcompanys: [],
        wlcompany: '',
        farepricetypes: '',
        farepricetype: '',
        faretypes: '',
        faretype: '',
        carcode: '',
        packCity: '',
        existOrderCode: '',
        existOrderId: ''
      }
    },
    created() {
      //刷新
      if (location.href.indexOf("#reloaded") == -1) {
        location.href = location.href + "#reloaded";
        location.reload();
      }
    },
    components: {
      OrderBaseInfo,
      SalesOperationLogs2
    },
    mounted () {
      //日历初始化
      $("#datetime-picker").calendar();

      // $("#datetime-picker").change(function () {
      //   that.senddate = $(this).val().replace(/\//g, '-');
      // })
      //提交操作定位到页面底部
      //$('#bmlogs').css('margin-bottom', this.$refs.actHtml.offsetHeight);

      // if(location.href.indexOf("&reloaded")==-1){
      //   location.href=location.href+"&reloaded";
      //   location.reload();
      // }

      $('.weui-navbar__item').on('click', function () {
        $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');

        //内容切换
        $(".weui-tab__panel .weui_tab_bd_item_active").removeClass('weui_tab_bd_item_active');
        var data_toggle =jQuery(this).attr("href");
        $(data_toggle).addClass("weui_tab_bd_item_active");
      });

      let that = this;
      this.guid = this.$route.query.guid;
      this.nodeid = this.$route.query.nodeid;
      //this.guid = this.$parent.getQueryVariable('guid');


      //获取回显数据
      $.ajax({
        url: '/wlinfo/Wlinfo!toSendCar.action',
        data: {orderid:that.guid,orderType:2},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.msg == "success") {
            that.adata = {}
            // if(res.wlinfos == undefined ){
            //   that.adata.deliProvince = "";
            //   that.adata.deliCity="";
            //   that.adata.deliDistrict="";
            //   that.adata.arriProvince = "";
            //   that.adata.arriCity="";
            //   that.adata.arriDistrict="";
            //
            // }else{
            //   that.adatas = res.wlinfos;
              that.order = res.order;
              // for(let i = 0; i < that.adatas.length; i++){
              //   if(that.adatas[i].transtype == 2){
              //     that.bdata = that.adatas[i]
              //   }else{
                  that.adata = res.order;
                  if (that.wlcompanys.length != 0 && that.wlcompany == '') {
                    that.wlcompany = that.wlcompanys.filter(item =>{
                      return item.guid == that.adata.customerid;
                    })[0] || '';
                  }
              //   }
              // }
              // let items = res.wlinfoitems;
              // for(let i = 0; i < items.length; i++){
              //   if(items[i].wlinfoid == that.adata.guid){
              //     that.wlinfoitem = items[i]
              //   }
              // }
            // $('#orgguid').val(that.adata.orgguid);
            $('#deliprovince').val(that.adata.deliProvince + " " + that.adata.deliCity + " " +that.adata.deliDistrict);
            $('#arriprovince').val(that.adata.arriProvince + " " + that.adata.arriCity + " " +that.adata.arriDistrict);
            // $('#guid').val(that.adata.guid);
            // that.farepricetype = that.adata.farepricetype != 0 ? that.adata.farepricetype : '';
            // that.faretype = that.adata.faretype;
            // that.carcode = that.adata.carcode;
          } else if (res != undefined && res.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            that.toastError('系统出现异常!');
          }
        },
        complete: function () {

        }
      });
      //获取回显数据
      $.ajax({
        url: '/sales/Sellform!getWlCompany.action',
        data: {},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.info != null) {
            that.wlcompanys = res.info;
            if (that.adata != '{}' && that.adata != undefined && that.adata.customerid != undefined && that.wlcompany == '') {
              that.wlcompany = that.wlcompanys.filter(item =>{
                return item.guid == that.adata.customerid;
              })[0] || '';
            }
          } else if (res != undefined && res.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            that.toastError('系统出现异常!');
          }
        },
        complete: function () {

        }
      });

      //获取计价方式
      $.ajax({
        url: '/sales/Sellform!getDictEmnu.action',
        data: {dicttype:"94"},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.info != null && res.info != 'error') {
            that.farepricetypes = res.info;
          } else {
            that.toastError('获取计价方式失败!');
          }
        },
        complete: function () {

        }
      });
      //获取运费结算方式
      $.ajax({
        url: '/sales/Sellform!getDictEmnu.action',
        data: {dicttype:"19"},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.info != null && res.info != 'error') {
            that.faretypes = res.info;
          } else {
            that.toastError('获取运费结算方式失败!');
          }
        },
        complete: function () {

        }
      });

      $("#deliprovince").cityPicker({
        title: "请选择发货地址",
      });
      $("#arriprovince").cityPicker({
        title: "请选择收货地址"
      });

      this.getFiles();
      this.refuseflag = this.$route.query.refuseflag;
      this.getRefuseNodes();
      this.getboxTypes();
    },
    watch: {
      // faretype: function (val) {
      //   $('#faretypeC').select({
      //     title: "运费结算方式",
      //     items: [{ "title":"公司结算", "value": 1 },{ "title":"客户结算", "value": 2 }],
      //     onChange: function (data) {
      //       $('input[name="wlcompanyguid"]').val($('#wlcompany').data('values'));
      //       $('#faretype').val(data.values);
      //     }
      //   });
      // }
    },
    methods: {
      packfpType: function(type) {
        return type == 1 ? '元/车' : '元/吨';
      },
      getFiles: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Fileinfo!getFileinfo.action',
          params: {orderid: this.guid}
        }).then(response => {

          if (response.data.msg == 'success') {
            this.orderfiles = response.data.files;
          } else {
            //失败时不提示
          }
        });
      },
      deleteCar: function(){
        let that = this;
        var result = confirm("确认删除该派车信息？");
        if(!result){
          return;
        }
        var guid = $("#guid").val();
        if($('#carcode').val() == null || $('#carcode').val() == ""){
          that.toastText("该物流还没有进行派车");
          return;
        }
        $.ajax({
          url: '/wlinfo/Wlinfo!deleteCar.action',
          data: {linkcode : this.order.sellcode},
          type: "get",
          dataType: "json",
          success: function(res) {
            console.log("res",res)
            if(res.msg == "删除成功"){
              $('#carcode').val("");
              $("#driverphone").val("")
              $("#drivername").val("")
              $("#customerid").val("")
              $("#customername").val("")
              $("#fareprice").val("")
              $("#cn0").html("")
              $("#cn1").html("")
              $("#cn2").html("")
              $("#cn3").html("")
              $("#cn4").html("")
              $("#cn5").html("")
              $("#cn6").html("")
              that.toastText(res.msg)
              if (that.wlinfoitem.wlstatus == 2) {
                that.$router.push({name: 'Sellform'});
              }
            }else{
              that.toastText(res.msg)
              // return;
            }
          }
        });
      },
      deleteSeaCar: function(){
        let that = this;
        var result = confirm("确认删除该派船信息？");
        if(!result){
          return;
        }
        var guid = $("#guid").val();
        if($('#customeridSea').val() == null || $('#customeridSea').val() == ""){
          that.toastText("该物流还没有进行派船");
          return;
        }
        $.ajax({
          url: '/wlinfo/Wlinfo!deleteSeaCar.action',
          data: {linkcode : this.order.sellcode},
          type: "get",
          dataType: "json",
          success: function(res) {
            console.log("res",res)
            if(res.msg == "删除成功"){
              $('#containerNo').val("");
              $("#deliPort").val("")
              $("#arriPort").val("")
              $("#customeridSea").val("")
              $("#customernameSea").val("")
              that.toastText(res.msg)
              if (that.wlinfoitem.wlstatus == 2) {
                that.$router.push({name: 'Sellform'});
              }
            }else{
              that.toastText(res.msg)
              // return;
            }
          }
        });
      },
      editCarcode: function(e) {
        console.log(e.target.value)
        this.checkCarcode(e.target.value);
      },
      checkCarcode: function (val) {
        // $.ajax({
        //   url: '/wlinfo/Wlinfo!checkWlByCarcode.action',
        //   data: {carCode: e.target.value, status: 7},
        //   type: "get",
        //   dataType: "json",
        //   success: function (res) {
        //     console.log("res", res)
        //   }
        // });
        let that = this;
        $.ajax({
          url: '/wlinfo/Wlinfo!checkWlInfo.action',
          data: {carCode:val, orderid: that.order.guid},
          type: "get",
          dataType: "json",
          success: function(res) {
            console.log("checkWlInfo res",res)
            if (res.orderCode) {
              that.existOrderCode = res.orderCode;
              that.existOrderId = res.wlinfoId;
              $('#guid').val(that.existOrderId);
            }
          }
        });
      },
      send: function() {
        let that = this;
        // if(that.adata.carcode != $('#carcode').val()){
        //   if($('#carcode').val().length == 7 ){
        //   $.ajax({
        //     url: '/wlinfo/Wlinfo!checkWlByCarcode.action',
        //     data: {carCode:$('#carcode').val(), guid : $("#guid").val()},
        //     type: "get",
        //     async: false,
        //     dataType: "json",
        //     success: function(res) {
        //       console.log("checkWlByCarcode",res);
        //       if(res.result == "false"){
        //         that.toastText("该车已不能派送");
        //         return;
        //       }else{
        if(!checkSubmit(that)){
          return;
        }

        //防止重复提交
        $('.subbtn').attr("disabled",true).css("pointer-events","none");
        //显示提交状态
        $.showLoading("正在提交");

              let postData = that.serialize2Obj($("#formid").serializeArray());
              postData.opinion = $('#opinion').val();
              if (postData.pingche) {
                postData.pingche = 2;
                postData['entity.wlinfoId'] = that.existOrderId;
              }
              that.axios({
                method: 'post',
                url: '/wlinfo/Wlinfo!sendCar.action?nodeid=' + that.nodeid,
                params: postData
              }).then(response => {
                //恢复提交按钮可点击
                $('.subbtn').attr('disabled', false).css("pointer-events","auto");
                //关闭提交状态
                $.hideLoading();
                console.log('response:', response)
                if(response.data.info == "ok"){
                  that.toastSuccess('操作成功!');
                  that.$router.push({name: 'Sellform'});
                } else if (response.data.info == 'canotopt') {
                  that.toastError('不允许的操作！');
                }else{
                  that.toastError('操作失败!');

                }
              }).catch(function (error) {
                //恢复提交按钮可点击
                $('.subbtn').attr('disabled', false).css("pointer-events","auto");
                //关闭提交状态
                $.hideLoading();
                that.toastError('系统错误');
              });

        // }
        //   }
        // });
      },
      serialize2Obj: function (data) {
        var obj = {};
        $.each(data,function(i,v){
          obj[v.name] = v.value;
        })
        return obj;
      },
      getboxTypes: function() {
        this.axios({
          url: '/sales/Boxtype!getBox.action'
        }).then(response => {
          if (response.data.msg == "success") {
            this.boxTypes = response.data.boxs;
          } else {
            this.toastText(获取箱型数据失败);
          }
        })
      },
      getWLDriver:function(){
        let that = this;
        this.axios({
          method: 'post',
          responseType: 'json',
          headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
          url: '/wlinfo/Wlinfo!getWlDriver.action',
          params: {mobilephone:$('#driverphone').val()}
        }).then(response => {
          console.log("response",response)

          var res = response.data;
          if (res.info != 'error' && res.info != 'wlError'  ) {
            var info = res.info;
            //判断司机是否有订单
            //  let isOrder = info.isOrder;
            //  if(isOrder == "true"){
            //      this.transferapplys = info.transferapplys;
            //      this.sellforms = info.sellforms;
            //  }else{
            //      // $.confirm("是否拼装？", function () {
            //      //
            //      //     that.transferapplys = [{"status":"已完成","createtime": "2020-4-2","code":"11122222","fromsrname":"宇","tosrname":"客户","applyname":"申请人"}]
            //      //     that.sellforms =  [{"status":"已完成","createtime":  "2020-4-2","sellcode":"11122222","applyname":"宇","customername":"客户"}]
            //      // })
            //      that.transferapplys = [{"status":"已完成","createtime": "2020-4-2","code":"11122222","fromsrname":"宇","tosrname":"客户","applyname":"申请人"}]
            //      that.sellforms =  [{"status":"已完成","createtime":  "2020-4-2","sellcode":"11122222","applyname":"宇","customername":"客户"}]

            //  }



            //赋值司机信息
            let driveInfo =  info.driveInfo;
            that.adata.drivername = driveInfo.drivername
            that.adata.driverphone = driveInfo.driverphone
            that.carcode = driveInfo.code;
            $("#drivername").val(driveInfo.drivername);
            $("#carcode").val(driveInfo.code);
            that.setValues();
            if (that.carcode) {
              that.checkCarcode(that.carcode);
            }
            //加载车牌号信息
            // that.loadCarCode(driveInfo.code);
            //如果不抛出异常，则会调用回调刷新方法
            // throw Exception;
            // that.checkCarcode;




          }
          // if(res.info == 'error' ){
          //   that.toastError('系统异常!');
          // }
          // if(res.info == 'wlError'){
          //   that.toastError('物流平台系统异常!');
          // }
        });
      },
      setValues :function (){
        this.adata.sellcode=$('#sellcode').val();
        this.adata.applyname=$('#applyname').val();
        this.adata.deliContact=$('#delicontact').val();
        this.adata.deliContactNo=$('#delicontacttel').val();
        this.adata.deliProvince=$('#deliprovince').val();
        this.adata.deliAddress=$('#deliaddress').val();
        this.adata.arriContact=$('#arricontact').val();
        this.adata.arriContactNo=$('#arricontacttel').val();
        this.adata.arriProvince=$('#arriprovince').val();
        this.adata.arriAddress=$('#arriaddres').val();
        this.adata.customerid=$('#customerid').val();
        this.adata.customername=$('#customername').val();
        this.adata.driverphone=$('#driverphone').val();
        this.adata.drivername=$('#drivername').val();
        this.adata.carcode=$('#carcode').val();
        this.adata.fareprice=$('#fareprice').val();
        this.adata.farepricetype=$('#farepricetype').val();

      },
      openLogs: function() {
        this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.guid, srguid: this.order.storermguid, departid: this.order.depguid}});
      },
      getRefuseNodes: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Flowtempnode!getRefuseNodes.action',
          params: {orderid: this.guid, nodeid: this.nodeid}
        }).then(response => {

          if (response.data.msg == 'success') {
            this.refuseNodes = response.data.optNodes.map(function (item) {
              return {text: item.name,
                onClick: function() {
                  $.confirm("确定要将订单回退到 " + item.name + " 节点？", function() {
                    that.doReject(item.guid, item.name, item.operatorid);
                  })
                }};
            });
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastText('获取可回退节点数据失败!');
          }
        });
      },
      rejectIt: function () {
        if (!this.checkEmy('opinion')) {
          this.toastText('意见不能为空！');
          return false;
        }
        if (this.refuseNodes.length > 0) {
          $.actions({
            title: '选择回退节点',
            actions: this.refuseNodes
          });
        } else {
          this.toastText('无可回退节点！');
          return false;
        }
      },
      doReject: function (refuseNodeid, refuseNodename, refuseOperatorid) {
        let that = this;

        //防止重复提交
        $('.subbtn').attr("disabled",true).css("pointer-events","none");
        //显示提交状态
        $.showLoading("正在提交");

        let postData = {};
        // postData.imgids = this.images.serverId.join(',');
        postData.imgids = '';
        postData.sellformid = this.guid;
        postData.opinion = ($('#opinion').val() || '') + ' 退回到' + refuseNodename;
        postData.nodeid = this.nodeid;
        postData.refuseNodeid = refuseNodeid;
        postData.backUserid = refuseOperatorid;
        this.axios({
          method: 'post',
          url: '/sales/Sellform!refuse.action',
          params: postData
        }).then((response) => {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();

          if (response.data.msg == 'success') {
            this.toastSuccess('提交成功!');
            this.$router.push({name: 'Sellform'});
          } else if (response.data.msg == 'canotRefuse') {
            this.toastText('不允许拒绝，需删除子订单！');
          } else if (response.data.msg == 'canotopt') {
            this.toastText('不允许的操作！');
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
        }).catch(function (error) {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();
          that.toastError('系统错误');
        });
      },
    }
  }

  /**
   * 提交之前的校验
   */
  function checkSubmit(that){
    //物流公司
    if(isEmpty("customerid")){
      alert("请选择物流公司");
      return false;
    }
    if(isEmpty("drivername")){
      alert("请填写司机姓名");
      return false;
    }
    if(isEmpty("driverphone")){
      alert("请填写司机电话");
      return false;
    }
    if(isEmpty("carcode")){
      alert("请填写车牌号");
      return false;
    }
    if(isEmpty("faretypeC")){
      alert("请选择结算方式");
      return false;
    }
    if(isEmpty("farepricetype")){
      alert("请选择运价方式");
      return false;
    }

    if(isEmpty("fareprice")){
      alert("请填写运价");
      return false;
    }

    if(isEmpty("delicontact")){
      alert("请填写发货联系人");
      return false;
    }
    if(isEmpty("delicontacttel")){
      alert("请填写发货联系人手机号");
      return false;
    }
    if(isEmpty("deliprovince")){
      alert("请填写发货地址");
      return false;
    }
    if(isEmpty("deliaddress")){
      alert("请填写发货详细地址");
      return false;
    }
    if(isEmpty("arricontact")){
      alert("请填写收货联系人");
      return false;
    }
    if(isEmpty("arricontacttel")){
      alert("请填写收货联系人手机号");
      return false;
    }if(isEmpty("arriprovince")){
      alert("请填写收货地址");
      return false;
    }if(isEmpty("arriaddres")){
      alert("请填写详细收货地址");
      return false;
    }








    return true;
  }

  function isEmpty(domID){

    return $('#' + domID).val() == "" || $('#' + domID) == null;
  }

</script>
<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .weui-cells_form {
    background: #fbfbfb;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }

  .weui-navbar a{
    text-decoration: none;color: #333;
  }

  .weui_tab_bd_item{
    display:none;height: 100%;overflow: auto;
  }

  .weui_tab_bd_item.weui_tab_bd_item_active{
    display:block;
  }

  *{
    list-style:none;
  }
  .delsty {
    position: absolute;
    top: 2px;
    right: 0px;
    z-index: 1000;
  }
  /*body{*/

  /*}*/
  .noprevent {
    pointer-events: none;
  }
</style>
